$(document).ready(function(){
    /* client-side form validation */
    // artist form validation
    $("#artistForm").validate({
        rules: {
            artist: "required"
        },
        messages: {
            artist: "Insert an artist"
        },
        errorElement: "li",
        errorClass: "error-single"
    });
    // location form validation
    $("#locationForm").validate({
        rules: {
            location: "required"
        },
        messages: {
            location: "Insert an location"
        },
        errorElement: "li",
        errorClass: "error-multi"
    });
    // venue form validation
    $("#venueForm").validate({
        rules: {
            venue: "required"
        },
        messages: {
            venue: "Insert an venue"
        },
        errorElement: "li",
        errorClass: "error-multi"
    });
    /* collapse panel */
    $('div.collapsePanelHeader > .icon').toggle(
        function() {
            $(this).parent().next().animate({
                "height": "toggle",
                "opacity": "toggle"
            }, "fast");
            $(this).attr("class", "icon expand");
        },
        function() {
            $(this).parent().next().animate({
                "height": "toggle",
                "opacity": "toggle"
            }, "fast");
            $(this).attr("class", "icon collapse");
        });

    $('.miniCollapsePanelHeader').live('click', function() {
        var panel = $(this).children().nextAll('.icon:first');
        if(panel.hasClass('expand')) {
            panel.removeClass('expand').addClass('collapse');
        }
        else {
            panel.removeClass('collapse').addClass('expand');
        }

        $(this).nextAll('.miniCollapsePanelContent:first').animate({
            "height": "toggle",
            "opacity": "toggle"
        }, "fast");
    });

});